package com.sitanyun.merchant.guide.frament.view.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.base.BaseActivity;
import com.sitanyun.merchant.guide.bean.EmpdialsBean;
import com.sitanyun.merchant.guide.callback.StringCallbacks;
import com.sitanyun.merchant.guide.url.Urls;
import com.sitanyun.merchant.guide.weiht.SharedPreferenceUtil;
import com.zhy.http.okhttp.OkHttpUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
import okhttp3.Call;

/**
 * 员工管理详情
 */
public class RegistrationPosterActivity extends BaseActivity {

    @BindView(R.id.user_herder_image)
    CircleImageView userHerderImage;
    @BindView(R.id.ll_image)
    LinearLayout llImage;
    @BindView(R.id.user_name)
    TextView userName;
    @BindView(R.id.ll_name)
    LinearLayout llName;
    @BindView(R.id.user_phone)
    TextView userPhone;
    @BindView(R.id.ll_phone)
    LinearLayout llPhone;
    @BindView(R.id.user_wxm)
    ImageView userWxm;
    @BindView(R.id.ll_wx)
    LinearLayout llWx;
    @BindView(R.id.user_zy)
    TextView userZy;
    @BindView(R.id.ll_zy)
    LinearLayout llZy;
    @BindView(R.id.user_shop)
    TextView userShop;
    @BindView(R.id.ll_shop)
    LinearLayout llShop;
    @BindView(R.id.user_enter)
    TextView userEnter;
    @BindView(R.id.ll_enter)
    LinearLayout llEnter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_registration_poster;
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        setFindViewById(true);
        setTitleStr("基本信息");
        OkHttpUtils.get().url(Urls.querydetail + "/" + Long.valueOf(getIntent().getStringExtra("starffid")))
                .addHeader("Content-Type", "application/json")
                .addHeader("Authorization", "Bearer " + SharedPreferenceUtil.getStringData("token"))
                .build().execute(new StringCallbacks() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                EmpdialsBean empdialsBean = new Gson().fromJson(response, EmpdialsBean.class);
                if (empdialsBean.getCode() == 0) {
                    Glide.with(RegistrationPosterActivity.this).load(empdialsBean.getData().getHeadImg())
                            .error(R.mipmap.cimg).into(userHerderImage);
                   userName.setText(empdialsBean.getData().getStaffName());
                    userPhone.setText(empdialsBean.getData().getPhone());
                    Glide.with(RegistrationPosterActivity.this).load(empdialsBean.getData().getQrcode())
                          .into(userWxm);
                   userZy.setText(empdialsBean.getData().getRoleName());
                    userShop.setText(empdialsBean.getData().getStoreName());
                    userEnter.setText(empdialsBean.getData().getEnterpriseName());
                }
            }
        });
    }

    @Override
    public void initView() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
